package book.factory;

import util.DBUtil;
import edu.nf.SQLExecutor;

public class SQLExecutorFactory {
    private static ThreadLocal<SQLExecutor> se=new ThreadLocal<SQLExecutor>();
    private SQLExecutorFactory(){}
    public static SQLExecutor getSingletonSQLExecutor(){
        if(se.get()==null){
            se.set(new SQLExecutor(DBUtil.getConnection()));
            return se.get();
        }else{
            return se.get();
        }
    }
    public static SQLExecutor getPrototypeSQLExecutor(){
        return new SQLExecutor(DBUtil.getConnection());
    }
    public static void remove(){
        se.remove();
    }
}
